Ext.application({
	requires: ['Ext.container.Viewport'],
	name: 'cfbose',
	controllers: [
		'main'
	],
	
	appFolder: 'app',
	
	launch: function(){
		Ext.create('Ext.container.Viewport', {
			layout: 'border',
			items: [{
				region: 'north',
				flex: 2,
				xytpe: 'container'
			},{
				region: 'center',
				xtype: 'panel',
				flex: 3,
				layout: {
					type: 'vbox',
					align: 'center'
				},
				items: [{
					xtype: 'form',
					flex: 1,
					items: [{
						xtype: 'textfield',
						fieldLabel: 'User name',
						name: 'username',
						labelAlign: 'top',
						height: 45,
						allowBlank: false,
						cls: 'field-margin',
						emptyText: 'Type your user name or email...',
						width: 250
					},{
						xtype: 'textfield',
						fieldLabel: 'Password',
						name: 'password',
						inputType: 'password',
						height: 45,
						emptyText: 'Type your password...',
						labelAlign: 'top',
						allowBlank: false,
						cls: 'field-margin',
						width: 250
					},{
						xtype: 'displayfield',
						name: 'logindisplaymore',
						id: 'displayrespidid',
						value: '',
						cls: 'field-margin',
						width: 250
					}],
					
					buttons: [{
							text: 'Sign in',
							action: 'signin',
							handler: function() {
								if (this.up('form').getForm().isValid()) {
								  	this.up('form').submit({
								  		url: 'app/controller/main/signin.cfm',
								  		reset: true,
								  		method: 'POST',
								  		failure: function(form, action){
								  			
										 	form.setValues([{
												id: 'displayrespidid',
												value: action.result.form[0].detail
											}]);
											/*
											Ext.Msg.show({
								  				title: 'Failed to submit',
								  				msg: 'There is a problem in submitting the exit interview form.' + action.result.form[0].detail,
								  				buttons: Ext.Msg.OK,
								  				icon: Ext.Msg.ERROR
								  			});
											*/
								  		},
								  		success: function(form, action){
								  			window.location.reload();
								  		}
								  	});
								  } 
						}
						
						}]
					
				}]
				
				
			},{
				region: 'south',
				flex: 2
			}]
		
		});
	}
	
});

/*
Ext.onReady(function() {
	





});
*/

